<?php

class Controller_Search extends Controller {
	
	public function action_select() {
		$id = $this->request->param('id');
		$category = ORM::factory('category', $id);
		$subcategories = $category->subcategories->find_all();
		$options = '<option value="'.$category->id.'">All '.$category->name.'</option>';
		
		foreach($subcategories as $sub):
			$options .= '<option value="'.$sub->id.'">'.$sub->name.'</option>';
		endforeach;
		$this->response->body($options);
	}
}